package component
{
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.Shape;
	import flash.display.Sprite;
	
	public class LContainer extends Sprite
	{
		protected var _mask:Shape;
		public var content:Sprite;
		
		protected var _width:Number = 0;
		protected var _height:Number = 0;
		public function LContainer(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0)
		{
			this.x = xpos;
			this.y = ypos;
			init();
			if(parent != null)
			{
				parent.addChild(this);
			}
		}
		private function init():void{
			_mask = new Shape;
			super.addChild(_mask);
			
			content = new Sprite();
			super.addChild(content);
			content.mask = _mask;
		}
		override public function set width(w:Number):void
		{
			_width = w;
			draw();
		}
		override public function get width():Number
		{
			return _width;
		}
		override public function set height(h:Number):void
		{
			_height = h;
			draw();
		}
		override public function get height():Number
		{
			return _height;
		}
		public override function addChild(child:DisplayObject):DisplayObject
		{
			content.addChild(child);
			return child;
		}
		public function draw():void
		{
			_mask.graphics.clear();
			_mask.graphics.beginFill(0xff0000);
			_mask.graphics.drawRect(0, 0, _width, _height);
			_mask.graphics.endFill();
		}
	}
}